<?php
class template_content_article_listing extends theme
{

	protected function center()
	{
		$menu_id = $this->get('menu_id');
		$category_id = $this->get('category_id');
		$articles = $this->get('articles');
		$categories = $this->get('categories');
		?>

<div class="center-title"><?php echo $this->get_title(); ?></div>

<div class="center-body">	
	<p>
	选择分类: 
	<select onchange="javascript:window.location.href='./?action=content&task=articles&menu_id=<?php echo $menu_id; ?>&category_id='+this.options[this.selectedIndex].value;">
	<?php 
	
	$category_name = array();
	
	echo '<option value="-1"> - 所有文章 - </option>';
	foreach($categories as $category)
	{
		echo '<option value="'.$category->id.'"';
		if($category->id == $category_id) echo ' selected';
		echo '>';
		if($category->level) echo str_repeat('&nbsp; ', $category->level);
		echo '- '.$category->name.' -</option>';
		
		$category_name[$category->id] = $category->name;
	}
	?>
	</select>
	</p>
			
	<ul>
	<?php 
	if(count($articles))
	{
		foreach($articles as $article)
		{
			?>
			<li>
			[<a href="<?php echo url('./?action=content&task=articles&category_id='.$article->category_id.'&menu_id='.$menu_id ); ?>"><?php echo $category_name[$article->category_id]; ?></a>] 
			<a href="<?php echo url('./?action=content&task=article&article_id='.$article->id.'&menu_id='.$menu_id ); ?>"><?php echo $article->title; ?></a>
			</li>
			<?php
		}
	}
	else
	{
		echo '<li>没有记录</li>';
	}
	?>
	</ul>
	
	<p><?php $this->pagination(); ?></p>
</div>
		<?php
		
	}	

}
?>